package com.wnxy.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wnxy.dto.ManagerRoleDto;
import com.wnxy.model.Manager;
import com.wnxy.model.ManagerRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author alice
 * @since 2021-11-12
 */
public interface ManagerRoleMapper extends BaseMapper<ManagerRole> {
//连表查询用户角色
    @Select("<script>"+
            "SELECT * from t_manager man left join t_manager_role mr on man.manager_id=mr.manager_id " +
            "<where>" +
            "<if test='roleId!=null'>" +
            "mr.role_id=#{roleId}" +
            "</if>" +
            "</where>" +
            "</script>")
//    Page<ManagerRoleDto> findByrole(Page<Manager> page, @Param(Constants.WRAPPER) QueryWrapper<ManagerRole> qw);
    Page<ManagerRoleDto> findByrole(Page<Manager> page, @Param("roleId") Integer roleId);
}
